class Solution {
public:
    int jump(vector<int>& nums) {
        if (nums.size() == 1) return 0;
        int step = 0;
        int cover = 0;
        int nextCover = 0;
        for (int i = 0; i < nums.size(); ++i)
        {
            nextCover = max(nextCover, i + nums[i]);
            if (i == cover)
            {
                if (cover != nums.size() - 1)
                {
                    ++step;
                    cover = nextCover;
                    if (cover >= nums.size() - 1) break;
                }
                else break;
            }
        }
        return step;
    }
};